﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

using BLL;
using DAL;
using Models;
using System.Data;
using System.Text;
using System.Xml;
using Web.Old_App_Code;

public partial class backstage_order_postscript_set : System.Web.UI.Page
{
    // Fields

    protected string OrderPostcriptXmlPath = "/cn/xml/order_postscript.xml";
 

    // Methods
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.OrderPostcriptXmlPath));
            XmlElement element = document.SelectSingleNode("postscript/set") as XmlElement;
            element.SetAttribute("value", this.txtaPostscript.Value);
            element.SetAttribute("rows", this.txtRows.Value);
            element.SetAttribute("cols", this.txtCols.Value);
            document.Save(base.Server.MapPath(this.OrderPostcriptXmlPath));
            base.ClientScript.RegisterStartupScript(base.GetType(), "message", "<script language=\"javascript\" defer>alert(\"更新成功！\");location.href=\"order_list.aspx\";</script>");
        }
        catch
        {
            base.ClientScript.RegisterStartupScript(base.GetType(), "message", "<script language=\"javascript\" defer>alert(\"更新失败！\");</script>");
        }
    }

    private void OrderPostscriptBind()
    {
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.OrderPostcriptXmlPath));
            XmlElement element = document.SelectSingleNode("postscript/set") as XmlElement;
            this.txtRows.Value = element.GetAttribute("rows");
            this.txtCols.Value = element.GetAttribute("cols");
            this.txtaPostscript.Rows = Convert.ToInt32(element.GetAttribute("rows"));
            this.txtaPostscript.Cols = Convert.ToInt32(element.GetAttribute("cols"));
            this.txtaPostscript.Value = element.GetAttribute("value");
        }
        catch
        {
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if ((HttpContext.Current.Session["admin_user"] == null) && (HttpContext.Current.Session["language_version"] == null))
        {
            base.ClientScript.RegisterStartupScript(base.GetType(), "sJs", "top.location=\"login.html\";", true);
        }
        if (!base.IsPostBack)
        {
            this.OrderPostscriptBind();
        }
    }

}